clear
set more off

local titlescore "Occupational"

local titlemarr "Ever Married"
local titleall "All"

local criteriamarr "keep if ever_married == 1"
local criteriaall ""

foreach group in all marr {

*Ever Married by Quartile

foreach var in score{

***** 30 yr*****

use $tempdir/panel_trends_30yr_income.dta, clear
keep if race==1
`criteria`group''

gen anychildinhh = nchild > 0 if nchild != .

collapse (mean) anychildinhh nchild_mean = nchild (median) nchild_med = nchild logocc`var'_father, by(qtl_`var'_wgt_full sex year2)
drop if qtl_`var'_wgt_full==.

gen birth_cohort = year2 - 37.5 
gen quartile = qtl_`var'_wgt_full

graph twoway scatter anychildinhh birth_cohort if quartile==1 & sex==2, sort(year2) connect(direct) lcolor(ebg) lwidth(thick) mcolor(ebg) msymbol(circle)  || /*
	*/ scatter anychildinhh birth_cohort if quartile==2 & sex==2, sort(year2) connect(direct) lcolor(eltblue) lwidth(thick) mcolor(eltblue) msymbol(diamond)  || /*
	*/ scatter anychildinhh birth_cohort if quartile==3 & sex==2, sort(year2) connect(direct)  lcolor(ebblue) lwidth(thick) mcolor(ebblue) msymbol(triangle) || /*
	*/ scatter anychildinhh birth_cohort if quartile==4 & sex==2, sort(year2) connect(direct) lcolor(edkblue) lwidth(thick) mcolor(edkblue) msymbol(square) /*
	*/ legend(label(1 "Quartile 1 (lowest)") label(2 "Q2") label(3 "Q3") label(4 "Q4")) graphregion(color(white))/*
	*/ xtitle("15 year birth cohort") title("Fraction With Child in HH" "By Parental `title`var'' Income Quartile") subtitle("`title`group'' Women, Ages 30-45") ytitle("Fraction")
	
graph export "$outputdir/anychildhh_30yr_`var'_`group'women.pdf", replace

graph twoway scatter nchild_mean birth_cohort if quartile==1 & sex==2, sort(year2) connect(direct) lcolor(ebg) lwidth(thick) mcolor(ebg) msymbol(circle)  || /*
	*/ scatter nchild_mean birth_cohort if quartile==2 & sex==2, sort(year2) connect(direct) lcolor(eltblue) lwidth(thick) mcolor(eltblue) msymbol(diamond)  || /*
	*/ scatter nchild_mean birth_cohort if quartile==3 & sex==2, sort(year2) connect(direct)  lcolor(ebblue) lwidth(thick) mcolor(ebblue) msymbol(triangle) || /*
	*/ scatter nchild_mean birth_cohort if quartile==4 & sex==2, sort(year2) connect(direct) lcolor(edkblue) lwidth(thick) mcolor(edkblue) msymbol(square) /*
	*/ legend(label(1 "Quartile 1 (lowest)") label(2 "Q2") label(3 "Q3") label(4 "Q4")) graphregion(color(white))/*
	*/ xtitle("15 year birth cohort") title("Mean Children in HH" "By Parental `title`var'' Income Quartile") subtitle("`title`group'' Women, Ages 30-45") ytitle("Number of Children")

graph export "$outputdir/nchildhh_30yr_`var'_`group'women.pdf", replace	
}


}


